package player;
import ttt.*;
import tree.*;

public class ExpertAI implements Player {
	
	private Tree tree;
	
	public String toString() {
		return "Expert AI";
	}
	
	public void reset(int newMark) {
		if(tree != null)
			tree.reset(newMark);
	}
	
	public Point placeMark(TicTacToe t) {
		if(tree == null) {
			tree = new Tree(t.getPlayerMark(this));
			//System.out.println("Calculating first move...");
		}

		int i = Point.pointToIndex(t.getLastPlay());
		int move = tree.getNextMove(i);
		
		return Point.indexToPoint(move);
	}
}
